package com.mjh.action;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.mjh.bean.User;
import com.mjh.comm.Constant;
import com.opensymphony.xwork2.ActionSupport;

public class CommAction extends ActionSupport{

	private static final long serialVersionUID = -5969814568349114819L;

	private HashMap<String, String> articleState = new HashMap<String, String>();

	private String userName;
	
	private String passWord;
	
	public String requestArticleState(){
		return SUCCESS;
	}
	
	
	public HashMap<String, String> getArticleState() {
		articleState.put(String.valueOf(Constant.ARTICLE_STATE_NORMAL), Constant.ARTICLE_STATE_DESC[Constant.ARTICLE_STATE_NORMAL]);
		articleState.put(String.valueOf(Constant.ARTICLE_STATE_HIDDEN), Constant.ARTICLE_STATE_DESC[Constant.ARTICLE_STATE_HIDDEN]);
		return articleState;
	}
	
	public String login(){
		User user;
		if("mojiahuiAdmin".equals(userName) && "iamthebest".equals(passWord)){
			user = new User();
			user.setName("mojiahuiAdmin");
			user.setStatus(Constant.USER_NORMAL);
			HttpServletRequest request = ServletActionContext.getRequest ();
			request.getSession().setAttribute(Constant.LOGIN_KEY, user);
			return SUCCESS;
		} 
		return SUCCESS;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}


	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}
}
